﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MapleLib.WzLib;
using MapleLib.WzLib.WzProperties;

namespace MapleLib.Examples.MapEditor
{
	public partial class SelectMapForm : Form
	{

		public List<WzImage> availableMaps;
		public WzImage selectedImg;

		public SelectMapForm(List<WzImage> maps)
		{
			InitializeComponent();
			availableMaps = maps;
			foreach (WzImage img in availableMaps)
			{
				listBox1.Items.Add(img.Name);
			}
		}

		private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
		{
			int index = listBox1.SelectedIndex;
			button1.Enabled = index > -1;
			if (index > -1 && index < availableMaps.Count)
			{
				selectedImg = availableMaps[index];
				try
				{
					pictureBox1.Image = ((WzCanvasProperty)(availableMaps[index]["miniMap"]["canvas"])).PngProperty.PNG;
				}
				catch
				{
					pictureBox1.Image = null;
				}
			}
		}
	}
}